package org.geekbang.thinking.in.spring.bean.definition;

import org.geekbang.thinking.in.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Bean 别名实例
 *
 */
public class BeanAliasDemo {

    public static void main(String[] args) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:META-INF/bean-definition-context.xml");
        // 通过别名获取 Bean
        User wangsiqiUser = (User) beanFactory.getBean("wangsiqi-user");
        User user = (User) beanFactory.getBean("user");
        System.out.println(wangsiqiUser == user);
    }

}
